package LcOthers;

public class WaterContainer {
    public static void main(String[] args)
    {
        int [] a={1,8,6,2,5,4,8,3,7};
        int result=calCulate(a);
        System.out.println("容器最多可以装水的量是"+result);
    }

    public static int calCulate(int[] height)
    {
        int i=0,j=height.length-1;
        int res=0;
        while(i<j)
        {
            res=Math.max(Math.min(height[i],height[j])*(j-i),res);
            if(height[i]<height[j])
                i++;
            else
                j--;
        }
        return res;
    }
    
}
